{% if results %}

<table class="table table-bordered" style="margin-top: -20px">
    <tr>
        <th class="success" colspan="2">
            Results for this File
        </th>
    </tr>

    {% for parent_uid, file_result in results.items() %}

        <tr data-toggle="collapse" data-target="#collapse-{{ parent_uid }}">
            <td class="clickable" colspan=2>
                <i class="fas fa-angle-down"></i> {{ parent_uid | replace_uid_with_hid | safe }} -- {{ file_result.path }}
                {% if file_result.is_executable %}
                    <i class="fas fa-check text-success"></i>
                {% else %}
                    <i class="fas fa-times text-danger"></i>
                {% endif %}
            </td>
        </tr>

        <tr>
            <td colspan="2" class="qemu-td p-0">
                <div class="collapse" id="collapse-{{ parent_uid }}">
                    <table class="table table-bordered m-0" style="width: 100%">
                        <tr>
                            <td style="width: 175px;">Executable in QEMU:</td>
                            <td>{{ file_result.is_executable }}</td>
                        </tr>

                        {% if file_result.extended_results %}
                            <tr>
                                <td>Individual Results:</td>
                                <td class="p-0">
                                    <table class="table table-bordered m-0" style="width: 100%">
                                        {% for arch_result in file_result.extended_results %}
                                            <tr>
                                                {% set row_count = (arch_result.parameter_results | length) * 3 %}
                                                <td style="width: 1px;" rowspan="{{ row_count }}">
                                                    {{ arch_result.architecture }}
                                                </td>
                                            {% if arch_result.error %}
                                                <!-- error in docker container case -->
                                                <td><b class="text-danger">Error</b>: {{ arch_result.error }}</td>
                                            {% else %}
                                                <!-- no error case -->
                                                {% for option_result in arch_result.parameter_results %}
                                                    <td style="width: 1px;" rowspan="3">{{ option_result.parameters }}</td>
                                                    <td>stdout</td>
                                                    <td class="qemu-td" style="padding: 5px;">
                                                        {% if option_result.stdout %}
                                                            <pre class="qemu-pre">{{ '$ .' + file_result.path + ' ' + option_result.parameters + '\n' + option_result.stdout }}</pre>
                                                        {% else %}
                                                            Empty
                                                        {% endif %}
                                                    </td>
                                                    </tr><tr>
                                                    <td>stderr</td>
                                                    <td>
                                                        {% if option_result.stderr %}
                                                            {{ option_result.stderr }}
                                                        {% else %}
                                                            Empty
                                                        {% endif %}
                                                    </td>
                                                    </tr><tr>
                                                    <td>return code</td>
                                                    <td>{{ option_result.return_code }}</td>
                                                    </tr><tr>
                                                {% endfor %}
                                            {% endif %}
                                            <td style="width: 1px;">strace</td>
                                            <td colspan="2">
                                                {% if arch_result.strace %}
                                                    <pre class="qemu-pre">{{ arch_result.strace | decompress }}</pre>
                                                {% else %}
                                                    Empty
                                                {% endif %}
                                            </td>
                                            </tr>
                                        {% endfor %}
                                    </table>
                                </td>
                            </tr>
                        {% endif %}
                    </table>
                </div>
            </td>
        </tr>
    {% endfor %}
</table>

{% endif %}
